#ifndef _MAIN_H_
#define _MAIN_H_	1

// BYTE type definition
#ifndef _BYTE_DEF_
#define _BYTE_DEF_
typedef unsigned char BYTE;
#endif   /* _BYTE_DEF_ */

//-----------------------------------------------------------------------------
// Asignaci'on de puertos
//-----------------------------------------------------------------------------
#define	BootSwitch 0x01		// bit 0 del puerto 2 = boton de recarga

// UART
// P0.4 = TX_UART
// P0.5 = RX_UART

//-----------------------------------------------------------------------------
// Global CONSTANTS
//-----------------------------------------------------------------------------
#define	SYSCLK                  12000000
		
// Estados
#define	ST_IDLE                 0x01
#define	ST_ERROR                0x02
#define	ST_ACK_COMM             0x03
#define	ST_BOOTLOADER           0x04
#define	ST_CAPTURE              0x05
#define	ST_DEBUG                0xFF    // Para depurar el programa
#define	ST_NORMAL               0x06    // modo normal
#define	ST_SLEEP                0x07    // modo bajo consumo
#define	ST_TEST                 0x08

// Definiciones de led_status
#define	LED_BLINK               1
#define	LED_ON                  2
#define	LED_OFF                 3

// Commands
#define	COMM_OK                 0x8A
#define	COMM_ERROR              0xA8
#define	COMM_ERASE_ALL          0x73    // borra todas las memorias
// comandos para el debugging
#define COMM_START_CAPTURE      0x63
#define COMM_STOP_CAPTURE       0x36
#define COMM_ACK_TX             0x74

extern BYTE estado;
extern BYTE sub_estado;
extern BYTE led_status;
sbit TestLed = 0xA3; // led de prueba

#define RAW_BUFFER_SIZE 256
extern unsigned xdata raw_buffer[RAW_BUFFER_SIZE];
extern unsigned raw_buffer_next;

// Function prototypes
void Init_Principal(void);
void Ciclo_Principal(void);
void Main_Initialize(void);
void Port_Init(void);

// Macros

#endif
